#region Copyright & License
/* Tyng.Data
 * Copyright (c) 2007, Paul Tyng, All rights reserved.
 * Code licensed under the BSD License:
 * http://www.opensource.org/licenses/bsd-license.php
 * Downloaded from: http://code.google.com/p/tyngdata/
*/
#endregion

using System;
using System.Collections;
using System.ComponentModel;

namespace Tyng.Data
{
	internal sealed class TypeConverterFieldConverter : IFieldConverter
	{
		private TypeConverterFieldConverter() {}

		#region IFieldConverter Members

		public object ConvertFromString(Type toType, string data)
		{
			TypeConverter tc = TypeDescriptor.GetConverter(toType);

			return tc.ConvertFromString(data);
		}

		#endregion

		private static TypeConverterFieldConverter _default;

		public static TypeConverterFieldConverter Default 
		{ 
			get 
			{ 
				if(_default == null)
					_default = new TypeConverterFieldConverter();

				return _default; 
			} 
		}
	}
}
